package per.kongtouxu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import per.kongtouxu.domain.pojo.Admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class PageController {
     @RequestMapping("/page")
    public String pager(HttpServletRequest req, HttpServletResponse resp) {
         //获取前台发送过来的参数
         String p = req.getParameter("p");
         if(p !=null){
             Admin userInfo = (Admin) req.getSession().getAttribute("loginAdmin");
             System.out.println("admin："+userInfo);
             if(userInfo != null){
                 System.out.println("跳转到指定页面");
                 System.out.println("P:"+p);
                 return p;
                // return new ModelAndView(p);
             }else {
                 System.out.println("跳转login");
                 return "Login";
                 //return new ModelAndView("Login");
             }
         }else {
             return "Login";
         }
    }
}
